home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group01a.txt / 000011_icon-group-sender _Wed May 17 07:43:13 2000.msg < prev    next >
Internet Message Format  |  2002-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id HAA00794
  4.     for icon-group-addresses; Wed, 17 May 2000 07:42:44 -0700 (MST)
  5. Message-Id: <200005171442.HAA00794@baskerville.CS.Arizona.EDU>
  6. From: "Frank J. Lhota" <NOSPAM.Frank.Lhota@lexma.meitech.com>
  7. X-Newsgroups: comp.lang.icon
  8. Subject: Re: Reversible assignment really reversible ?
  9. X-Priority: 3
  10. X-MSMail-Priority: Normal
  11. X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
  12. X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
  13. Date: Wed, 17 May 2000 09:21:29 -0000
  14. X-Trace: client 958569712 38.163.203.81 (Wed, 17 May 2000 09:21:52 EDT)
  15. To: icon-group@optima.CS.Arizona.EDU
  16. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  17. Status: RO
  18. Content-Length: 1452
  19.  
  20.  
  21. "F.G. van DORP" <F.G.van.Dorp@digimedia.nl> wrote in message
  22. news:h553is4c3ulev333pul872qcr7e5uvubih@4ax.com...
  23. > BTW,
  24. > #-------------------------------------
  25. > procedure revass(a,b)
  26. > local c; c:=a
  27. > suspend (a:=b|(a:=c, &fail))
  28. > #-------------------------------------
  29. > doesn't seem to work in the 8queens example, neither
  30. > does MYREVASS() (without the &FAIL),
  31. > but that was no big surprise.
  32.  
  33. There may be a misunderstanding here. In Icon, all procedure parameters are
  34. passed by value, not by reference. When the procedure revass is called, a
  35. and b are assigned the values of the first and second actual parameters (or
  36. &null if these parameters are not specified). If the statements in revass
  37. changes in a and b, these changes are NOT copied back to the actual
  38. parameters. If we were to execute the following Icon code:
  39.  
  40.     c := 3
  41.     revass( c, 4 )
  42.  
  43. the value of c would not be affected. The revass function would assign 4 to
  44. the local variable a, but that would have no impact on c.
  45.  
  46. The situation is similar in the C language. The C function
  47.  
  48.     int Assign( int a, int b )
  49.     {
  50.         return ( a = b );
  51.     }
  52.  
  53. does NOT simulate C integer assignment, since the assignment statement ( a =
  54. b ) only changes the local variable a.
  55.  
  56. If you want to simulate reversible assignment, you need a more sophisticated
  57. approach. Icon structures such as lists and records use pointer semantics,
  58. and can be used to get the effect of pass by reference.
  59.  
  60.  
  61.